package com.mall.biz.comment;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.mall.client.comment.MallCommentService;
import com.mall.client.user.UserService;
import com.mall.pojo.MallComment;
import com.mall.query.Page;
import com.mall.vo.user.MallCommentVO;

@Service
public class MallCommentBizImpl {
	@Autowired
	private MallCommentService mallCommentService;
	@Autowired
	private UserService userService;
	

	public List<MallCommentVO> getMallCommentVOListByMallId(Long mallId, Integer status, Integer type, Page page) {
		List<MallComment> mallCommentList = this.mallCommentService.getMallCommentListByMallId(mallId, status, type,
				page);
		if (mallCommentList == null || mallCommentList.size() <= 0) {
			return null;
		}

		List<MallCommentVO> mallCommentVOList = new ArrayList<>();
		MallCommentVO mallCommentVO = null;
		for (MallComment mallComment : mallCommentList) {
			mallCommentVO = new MallCommentVO();
			mallCommentVO.setMallComment(mallComment);
			mallCommentVO.setUser(this.userService.getUserByUserId(mallComment.getUserId()));
			mallCommentVOList.add(mallCommentVO);
		}

		return mallCommentVOList;
	}

}
